package cn.aspart.validation.controller;

import cn.aspart.validation.bean.AnimalBean;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author aspart
 * @date 2020/10/21
 */
@RestController
@RequestMapping(path = "/validation")
public class ValidationDemoController {
    
    @PostMapping(path = {"/", ""})
    public Object validate(@RequestBody @Valid AnimalBean animalBean){
        return animalBean;
    }
    
    @GetMapping(path = "/get")
    public Object validate(@RequestParam @Validated @NotNull @Size(min = 6, max = 12) String name){
        return name;
    }
    
}
